<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .username {
            position: relative;
        }
        .username label {
            position: absolute;
            display: block;
            line-height: 24px;
            padding-left: 10px;
            left: 0;
            top:0;
            font-size: 12px;
            color: grey;
        }
    </style>
</head>
<body>
<div class="username">
    <input type="text" id="e" >
    <label id="lab" for="e">请输入</label>
</div>
<script>
    var oE = document.getElementById('e');
    var oLab = document.getElementById('lab');
    //键盘事件，松开键时触发
    oE.onkeyup = function () {
        if (oE.value != ''){
            oLab.style.display = 'none'
        }else {
            oLab.style.display = 'block'
        }
    }
</script>
</body>
</html>